<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>后台管理 - 易买网</title>
	<link type="text/css" rel="stylesheet" href="../css/style.css" />
	<link rel="stylesheet" type="text/css" href="../css/css.css">
	<script type="text/javascript" src="../scripts/function-manage.js"></script>
	<script type="text/javascript" src="../js/jquery-3.3.1.min.js"></script>
	<script type="text/javascript">
		$(function () {
			$.ajax({
				type:"POST",
				url:"../OrderGetAllByPageServlet",
				datatype:"json",
				success:function (data) {
					var html="<tr><th>"+'ID'+"</th><th>"+'姓名'+"</th><th>"+'发货地址'+"</th><th>"+'状态'+"</th><th>"+'操作'+"</th></tr>"
					for (var i = 0; i <data.length ; i++) {
						html+="<tr>"+
								"<td class='first w4 c'>"+data[i].eoId+"</td>"+
								"<td class='w1 c'>"+data[i].eoUsername+"</td>"+
								"<td>"+data[i].eoUserAddress+"</td>"+
								"<td class='w1 c'>"+getNameById(data[i].eoStatus)+"</td>"+
								"<td class='w1 c'><a href='order-modify.html?id="+data[i].eoId+"'>"+'修改'+"</a><a href='../OrderDeleteByEoIdServelt?id="+data[i].eoId+"'onclick='return sure();'>"+'删除'+"</a></td>"+
								"</tr>"
					}
					$("#table1").html(html);
				}
			})
		})
		function sure() {
			return confirm("是否删除");
		}
		function getNameById(x) {
			switch (x) {
				case 1:
					return   "下单";
					break;
				case 2:
					return  "审核通过";
					break;
				case 3:
					return  "配货";
					break;
				case 4:
					return "送货中";
					break;
				case 5:
					return "收获并确定";
					break;
				default:
					return "抱歉状态不能确定"
			}
		}

		function getNews(x) {
			$.ajax({
				type:"POST",
				url:"../OrderGetAllByPageServlet",
				datatype:"json",
				data:{
					"id":$(x).text()
				},
				success:function (data) {
					var html="<tr><th>"+'ID'+"</th><th>"+'姓名'+"</th><th>"+'发货地址'+"</th><th>"+'状态'+"</th><th>"+'操作'+"</th></tr>"
					for (var i = 0; i <data.length ; i++) {
						html+="<tr>"+
								"<td class='first w4 c'>"+data[i].eoId+"</td>"+
								"<td class='w1 c'>"+data[i].eoUsername+"</td>"+
								"<td>"+data[i].eoUserAddress+"</td>"+
								"<td class='w1 c'>"+getNameById(data[i].eoStatus)+"</td>"+
								"<td class='w1 c'><a href='order-modify.html?id="+data[i].eoId+"'>"+'修改'+"</a><a href='../OrderDeleteByEoIdServelt?id="+data[i].eoId+"'onclick='return sure();'>"+'删除'+"</a></td>"+
								"</tr>"
					}
					$("#table1").html(html);
				}
			})
		}
		function inquiryOrder() {
			$.ajax({
				type:"POST",
				url:"../OrderGetByIdNameServlet",
				dataType:"json",
				data:{
					"id":$("#dingDan").val(),
					"name":$("#myName").val()
				},
				success:function (data) {
					var html = "<tr><th>" + 'ID' + "</th><th>" + '姓名' + "</th><th>" + '发货地址' + "</th><th>" + '状态' + "</th><th>" + '操作' + "</th></tr>"
					for (var i = 0; i < data.length; i++) {
						html += "<tr>" +
								"<td class='first w4 c'>" + data[i].eoId + "</td>" +
								"<td class='w1 c'>" + data[i].eoUsername + "</td>" +
								"<td>" + data[i].eoUserAddress + "</td>" +
								"<td class='w1 c'>" + getNameById(data[i].eoStatus) + "</td>" +
								"<td class='w1 c'><a href='order-modify.html?id="+data[i].eoId+"'>" + '修改' + "</a><a href='../OrderDeleteByEoIdServelt?id="+data[i].eoId+"'onclick='return sure();'>" + '删除' + "</a></td>" +
								"</tr>"
					}
					$("#table1").html(html);
				}
			})
		}
		$(function () {
			$.ajax({
				type: "POST",
				url: "../OrderGetPageServlet",
				success: function (data) {
					var html="<li><a href='#' onclick='getNews(this)'>"+'上一页'+"</a></li>";
					for (var i = 1; i <=data ; i++) {
						html+="<li><a href='#' onclick='getNews(this)'>"+i+"</a></li>"
					}
					html+="<li><a href='#' onclick='getNews(this)'>"+'下一页'+"</a></li>"
					$("#ullll").html(html);
				}
			})
		})
	</script>
</head>
<body>
	<div class="main">
		<h2>订单管理</h2>
		<div class="manage">
			<div class="conform">
				<form>
					<div class="cfD">
						<input class="userinput" type="text" name="orderId" id="dingDan" placeholder="订单号" />
						&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;
						<input class="userinput vpr" type="text" name="userName" id="myName" placeholder="订货人" />
						<input type="button" class="userbtn" onclick="inquiryOrder()" value="查询">
						<!--<button class="userbtn" onclick="inquiryOrder()" name="submit" >查询</button>-->
					</div>
				</form>
			</div>

			<div class="spacer"></div>

			<!--列表显示-->
			<table class="list" id="table1">

			</table>

			<!--分页-->
			<div class="pager">
				<ul class="clearfix" id="ullll">
				</ul>
			</div>
		</div>
	</div>

</body>
</html>
